package com.itheima.web;

import com.itheima.dto.SlideBlockValidateCodeDTO;
import com.itheima.service.OrderService;
import com.itheima.support.Result;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {
    @DubboReference
    private OrderService orderService;

    @RequestMapping("/validate/{telephone}")
    public Result validate(@PathVariable("telephone") String telephone, @RequestBody() SlideBlockValidateCodeDTO slideBlockValidateCodeDTO){
        return new Result(orderService.validate(telephone,slideBlockValidateCodeDTO));
    }

    @PostMapping("/add")
    public Result add(@RequestBody Map map){
        return new Result(orderService.add(map));
    }

    @GetMapping("/findById/{id}")
    public Result findMSGById(@PathVariable("id") Long id){
        return new Result(orderService.findMSGById(id));
    }

    @GetMapping("/findStatusById/{id}")
    public Result findStatusById(@PathVariable("id") Long id) {
        return new Result(orderService.findStatusById(id));
    }


}
